# import os
# from multiprocessing import Process
#
# def run_proc(name):
#     print("Child process {a} ({b}) Running...".format(a=name,b=os.getpid()))
#
# if __name__ == '__main__':
#     print("Parent process {a}.".format(a=os.getpid()))
#     for i in range(5):
#         p = Process(target=run_proc,args=(str(i)))
#         print("Process will start.")
#         p.start()
#     p.join()
#     print("Process end")

# from multiprocessing import Pool
# import os,time,random
# def run_task(name):
#     print("Task {a} (pid={b}) is running...".format(a=name,b=os.getpid()))
#     time.sleep(random.random()*3)
#     print("Task {a} end.".format(a=name))
# if __name__ == "__main__":
#     print("Current process {a}.".format(a=os.getpid()))
#     p=Pool(processes=3)
#     for i in range(5):
#         p.apply_async(run_task,args=(i,))
#     print("Waiting for all subprocesses done")
#     p.close()
#     p.join()
#     print("All subprocesses done")

# import os
# if __name__ == "__main__":
#     print("current Process {a} start ...".format(a=os.getpid()))
#     pid = os.fork()
#     if pid < 0:
#         print("error in fork")
#     elif pid == 0:
#         print("I am child process({a}) and my parent is ({b})".format(a=os.getpid(),b=os.getppid()))
#     else:
#         print("I({a}) create a child process ({b}).".format(os.getpid(),pid))